package main

import (
	"fmt"
	"log"
	"net"
	"net/url"
	"time"
)

func checkServer(host string, port string)  bool {
	timeout := time.Second
	conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout)
	if err != nil {
		log.Println("Connecting error:", err)
		return false
	}
	if conn == nil {
		log.Println("Closed", net.JoinHostPort(host, port))
		return false
	}
	defer conn.Close()
	fmt.Println("Opened", net.JoinHostPort(host, port))

	return true
}

func main() {
	urlStr := "https://10.200.8.150:9345"
	u,_ := url.Parse(urlStr)
	b := checkServer(u.Hostname(), u.Port())
	fmt.Println(b)
}
